package com.activelife.test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TMysql {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	// 数据库连接
	private static final String URL = "jdbc:mysql://localhost:3306/";
	private static final String NAME = "mdao";
	private static final String PASS = "mdao";
	private static final String DRIVER = "com.mysql.jdbc.Driver";
	private Connection con;

	/*
	 * 构造函数
	 */
	public TMysql() {
		// 创建连接
		try {
			try {
				Class.forName(DRIVER);
			} catch (ClassNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			con = DriverManager.getConnection(URL, NAME, PASS);
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// try {
			// con.close();
			// } catch (SQLException e) {
			// // TODO Auto-generated catch block
			// e.printStackTrace();
			// }
		}
	}

	public void genFormTable(String tablename) throws SQLException {
		// 查要生成实体类的表
		String sql = "show table status like '" + tablename + "'";
		PreparedStatement pStemt = con.prepareStatement(sql);
		ResultSet resultSet = pStemt.executeQuery();
		while (resultSet.next()) {
			resultSet.getString(0);
		}
	
	}

	/**
	 * 出口 TODO
	 * 
	 * @param args
	 */
	public static void main(String[] args) {

		TMysql gem = new TMysql();
		try {
			gem.genFormTable(null);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
